import request from '@/utils/request'
// 获取员工列表
export const getEmployeeListApi = (params) => request({
  url: '/sys/user',
  params
})

// 导出员工的excel
export const exportEmployeeApi = () => request({
  url: '/sys/user/export',
  // 改变接收数据的类型
  responseType: 'blob' // 使用blob接收二进制文件流
})

// 下载员工导入模板
export const getExportTemplateApi = () => request({
  url: '/sys/user/import/template',
  responseType: 'blob' // 二进制文件流
})
// 上传用户的excel
export const uploadExcelApi = (data) => request({
  url: '/sys/user/import',
  method: 'post',
  data // form-data类型 因为要上传文件类型
})
// 删除员工
export const delEmployeeApi = (id) => request({
  method: 'delete',
  url: `/sys/user/${id}`
})
// 新增员工
export const addEmployeeApi = (data) => request({
  url: '/sys/user',
  method: 'post',
  data
})
// 获取员工详情
export const getEmployeeDetailApi = (id) => request({
  url: `/sys/user/${id}`
})
// 编辑员工
export const updateEmployeeApi = (data) => request({
  url: `/sys/user/${data.id}`,
  method: 'put',
  data
})

// 获取可用的角色
export const getEnableRoleListApi = () => request({
  url: '/sys/role/list/enabled'
})

// 分配员工角色
export const assignRoleApi = (data) => request({
  url: '/sys/user/assignRoles',
  method: 'put',
  data
})

// 群发通知接口
export const sendMultiMessageApi = data => request.post('/sys/messageMuch', data)
// 获取用户消息
export const getUserMessageApi = () => request.get('/sys/message')
// 删除用户信息
export const delUserMessageApi = id => request.delete(`/sys/message/${id}`)
// 已读消息
export const updateUserMessageApi = id => request.put(`/sys/message/${id}`)
